const logger = require('../logs/logger');
const brandSvr = require('../svrs/brandSvr');
const msgSvr = require('../svrs/msgSvr');
const cmtSvr = require('../svrs/cmtSvr');

var _mq = null;

module.exports = {
    set mq(value) {
        _mq = value;
    },

    subscribe(){
        _mq.subscribe('profile', origin => {
            var profile = JSON.parse(origin);
            brandSvr.add(profile);
        });

        _mq.subscribe('msg', origin => {
            var msg = JSON.parse(origin);
            msgSvr.add(msg);
        });

        _mq.subscribe('msgext', origin => {
            var msgext = JSON.parse(origin);
            msgSvr.update(msgext);
        });

        _mq.subscribe('cmt', origin => {
            var cmt = JSON.parse(origin);
            cmtSvr.add(cmt);
        });
    }
};